Trò chơi đua xe động vật trong UNITY Engine
114.953 lượt xem;
1 using UnityEngine;
2 using System.Collections;
3
4 namespace Helper
5 {
6
7 public class CloseListener : InputAdapter
8 {
9 public GameObject blackScreen;
10
11 public void Update()
12 {
13 if (Input.GetKeyDown(KeyCode.Backspace) || Input.GetKeyDown(KeyCode.Escape))
14 {
15 if (InputController.Name == InputNames.DIALOG)
16 {
17 blackScreen.SetActive(false);
18 gameObject.transform.parent.gameObject.SetActive(false);
19 InputController.Name = InputNames.MAINMENU;
20 }
21 }
22 }
23
24 public override void OnTouchDown()
25 {
26 if (InputController.Name == InputNames.DIALOG)
27 {
28 base.OnTouchDown();
29 transform.localScale = new Vector3(0.9f, 0.9f, transform.localScale.z);
30 gameObject.GetComponent<SpriteRenderer>().color = new Color(0.5f, 0.5f, 0.5f, 1);
31 }
32 }
33
34 public override void OnCheckUp()
35 {
36 if (InputController.Name == InputNames.DIALOG)
37 {
38 base.OnCheckUp();
39 transform.localScale = new Vector3(1, 1, transform.localScale.z);
40 gameObject.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 1);
41 }
42 }
43
44 public override void OnTouchUp()
45 {
46 if (InputController.Name == InputNames.DIALOG)
47 {
48 SoundManager.playButtonSound();
49 blackScreen.SetActive(false);
50 gameObject.transform.parent.gameObject.SetActive(false);
51 InputController.Name = InputNames.MAINMENU;
52 }
53 }
54 }
55 }
2 using System.Collections;
3
4 namespace Helper
5 {
6
7 public class CloseListener : InputAdapter
8 {
9 public GameObject blackScreen;
10
11 public void Update()
12 {
13 if (Input.GetKeyDown(KeyCode.Backspace) || Input.GetKeyDown(KeyCode.Escape))
14 {
15 if (InputController.Name == InputNames.DIALOG)
16 {
17 blackScreen.SetActive(false);
18 gameObject.transform.parent.gameObject.SetActive(false);
19 InputController.Name = InputNames.MAINMENU;
20 }
21 }
22 }
23
24 public override void OnTouchDown()
25 {
26 if (InputController.Name == InputNames.DIALOG)
27 {
28 base.OnTouchDown();
29 transform.localScale = new Vector3(0.9f, 0.9f, transform.localScale.z);
30 gameObject.GetComponent<SpriteRenderer>().color = new Color(0.5f, 0.5f, 0.5f, 1);
31 }
32 }
33
34 public override void OnCheckUp()
35 {
36 if (InputController.Name == InputNames.DIALOG)
37 {
38 base.OnCheckUp();
39 transform.localScale = new Vector3(1, 1, transform.localScale.z);
40 gameObject.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 1);
41 }
42 }
43
44 public override void OnTouchUp()
45 {
46 if (InputController.Name == InputNames.DIALOG)
47 {
48 SoundManager.playButtonSound();
49 blackScreen.SetActive(false);
50 gameObject.transform.parent.gameObject.SetActive(false);
51 InputController.Name = InputNames.MAINMENU;
52 }
53 }
54 }
55 }